Skip to content

fix(server): follow-ups whose results share one wake run both settle - #39220

Open
juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-39204
Open

juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-39204

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

When two follow-ups sent to the same delegated subagent both finished in one child turn (for example, one follow-up's completion notice was steered into the other's wake run), only the first was marked completed. The second stayed running forever with its result undelivered, so the parent kept listing it as background work. The server now settles each task from that shared run and delivers both results to the parent.

Fixes #39204

Reproduction on main

On origin/main 8d5e0b2 I wrote a test in apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts ('subagent follow-ups' > 'settles both follow-ups whose subagents' results share one wake'). It runs the real OrchestratorV2, EventSink, projections and recoverDelegatedTasks, the same pattern as the existing 'holds a follow-up open while the child's own subagent still runs'. Steps: (1) seed a parent with a completed async delegated child; (2) dispatch follow-up A to the child; it records a running nested subagent and its run completes; (3) dispatch follow-up B the same way; (4) B's nested subagent completes and opens an untagged wake run, whose user message has delegatedCompletion.parentRunId = B's run; (5) A's nested subagent completes, and its notice is written into the same running wake run (the steer); (6) the wake writes an assistant reply and completes. Observed: A's task is 'completed' with the wake's reply, and B's task stays 'running' with result null (assertion: 'follow-up ...:ordinal:3 never settled: expected running to equal completed'). Disabling only the existingResultTransfer early return in finalizeAppOwnedSubagentTask makes the test pass, which confirms that guard skips B. Not run with a live provider: it needs Codex automatically steering a delegated completion, and this VM has no ChatGPT OAuth.

Evidence

Being captured: before and after in the real app. This section is filled in before the pull request can merge.

Tests

  • vp test run src/orchestration-v2/DelegatedCompletionDelivery.test.ts -t "share one wake" on the repro branch before the fix: failed (follow-up ordinal 3 stayed running)
  • vp test run src/orchestration-v2/DelegatedCompletionDelivery.test.ts after the fix: 67 passed
  • vp test run src/orchestration-v2/RemoteDelegatedTask.test.ts src/orchestration-v2/RestartBackgroundNote.test.ts src/orchestration-v2/RestartContinuation.test.ts src/orchestration-v2/SubagentProjection.test.ts: 76 passed
  • vp test run src/mcp/OrchestratorMcpService.test.ts src/orchestration-v2/ThreadStop.test.ts src/orchestration-v2/ProjectionRecovery.test.ts src/mcp/OrchestratorMcpToolkit.integration.test.ts: 167 passed
  • vp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and tests (5 files, 103 tests) all passed

Not in this change

  • The batch loop in finalizeAppOwnedSubagent skips a task with a result if the child has any subagent_result transfer to the parent, not one for that task; settled tasks are the only ones it skips, so it does not cause this bug and I left it alone.
  • Not verified with a live provider: steering a delegated completion into a running wake needs Codex with ChatGPT OAuth, which the VM does not have.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

juliusmarminge and others added 2 commits November 19, 2026 16:46
Reproduces #39204: the second follow-up stays running because the
finalizer finds the first one's result transfer from the shared wake.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The finalizer took any subagent_result transfer from the result run as
proof the task had settled. Two follow-ups can share a wake run, so the
second one never settled. Count the transfer only once the task holds
its result.

Fixes #39204

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: e37e45f · PR result: e59c8fc · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The finalizer now requires both a non-null task result and a matching result transfer before it skips settlement. A regression test covers two delegated follow-ups whose grandchildren results are acknowledged by one untagged wake run.

Changes: Shared wake completion

Layer / File(s) Summary
Finalizer guard and shared-wake regression
apps/server/src/orchestration-v2/Orchestrator.ts, apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts
The finalizer skips settlement only when the task has a result and a matching transfer. The test verifies that recovery completes both follow-up tasks with the shared wake result.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • pingdotgg/t3code#33539: Changes follow-up finalization and result-transfer lookup for wake runs, which overlaps with this PR’s finalization path.
  • pingdotgg/t3code#23300: Changes result transfer for promoted delegated follow-ups, which shares the result-transfer behavior addressed here.

Suggested reviewers: t3dotgg, yash-singh1, maria-rcks, macroscopeapp

Merge Risk: Minimal · up to e59c8

This change lets two delegated follow-ups that share one wake run both settle and receive their results, as intended. No concrete merge-blocking defect was established. How MCP result retrieval handles the shared transfers was not fully confirmed, but the available evidence does not show a failure.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and its scope: follow-ups whose results share one wake run now both settle. The Orchestrator.ts change to finalizeAppOwnedSubagentTask and the new regression test both match th…
Description check Passed The description follows the template well. It has a problem statement, a change explanation, a linked issue (fixes #39204), a reproduction, and a detailed verification section with foc…
Linked Issues check Passed Issue #39204 requires that two follow-ups whose results share one wake run both settle, and that both results reach the parent. The PR changes finalizeAppOwnedSubagentTask in Orchestrator.ts so an exi…
Out of Scope Changes check Passed The PR changes two files per the raw summary: a regression test in DelegatedCompletionDelivery.test.ts (+207 lines) and the finalizeAppOwnedSubagentTask guard in Orchestrator.ts (+13/-11). Both direct…
Full details: Title check

Explanation

The title names the fix and its scope: follow-ups whose results share one wake run now both settle. The Orchestrator.ts change to finalizeAppOwnedSubagentTask and the new regression test both match this. The title is specific and follows the conventional commit form. It is not vague, and it does not describe anything absent from the changeset.

Full details: Description check

Explanation

The description follows the template well. It has a problem statement, a change explanation, a linked issue (fixes #39204), a reproduction, and a detailed verification section with focused test commands and observed results. Two gaps remain. The Scope section does not explain the bug in a self-contained way beyond the linked issue, and the Evidence section is an unfilled placeholder that says it must be completed before merge. Under the template, UI screenshots are not required because this is a server-side fix, so the placeholder is the main missing item.

Resolution

Remove or complete the Evidence placeholder. It states that before and after proof is pending and that it must be filled in before merge. For a server-only fix with no UI change, state that no UI evidence applies, or add the captured before and after output. Consider stating in the Scope section that the bug is tracked by issue #39204.

Full details: Linked Issues check

Explanation

Issue #39204 requires that two follow-ups whose results share one wake run both settle, and that both results reach the parent. The PR changes finalizeAppOwnedSubagentTask in Orchestrator.ts so an existing result transfer ends finalization only when the task already has a non-null result. Per the PR description and the raw summary, the regression test 'settles both follow-ups whose subagents' results share one wake' in DelegatedCompletionDelivery.test.ts reproduces the bug on the base commit (follow-up ordinal 3 stayed running) and passes after the change (67 tests in the file pass). The issue's suggested mechanism (targetTaskId on transfers and task-level deduplication in the MCP result lookup) is not adopted. That mechanism is a suggested local fix, not a stated requirement, and the issue's observable requirements are met by the guard change. Limits: the repository diff could not be read (changed blobs missing from the checkout), so the code change is assessed from the PR description and raw summary, not from the source. The live-provider steering path is not verified, as the PR states.

Full details: Out of Scope Changes check

Explanation

The PR changes two files per the raw summary: a regression test in DelegatedCompletionDelivery.test.ts (+207 lines) and the finalizeAppOwnedSubagentTask guard in Orchestrator.ts (+13/-11). Both directly serve issue #39204. The PR text states that the batch-loop behavior in finalizeAppOwnedSubagent is left unchanged, so no unrelated change is introduced. Limits: the repository diff could not be read, so the line-level content of Orchestrator.ts was not checked. The assessment relies on the summary and PR description.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e37e45f and e59c8fc.

Files selected for processing: 2

  • apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts
  • apps/server/src/orchestration-v2/Orchestrator.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@juliusmarminge

Copy link
Copy Markdown
Member Author

The automated pipeline stopped on this pull request and will not merge it:

the fix is written and reviewed, but proving it needs something no worker has:

  • Permanent blocker: The specified reproduction requires Codex automatically steering a delegated completion into an existing running wake and a signed-in ChatGPT OAuth account, which the brief lists as unavailable on every VM. Replay lacks active steering and cannot reproduce that sequence. Both completion settlement and delivery to the parent remain unverified on base and head.

It stays open for a person to finish or close.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two delegated follow-ups that finish in the same wake run settle only one; the other stays waiting

1 participant